<%@ tag pageEncoding="UTF-8"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!-- eg:  http:pcauto.com.cn/Id/type/pageNo/ -->
<c:set var="params" scope="request"><jsp:doBody/></c:set>
<c:set var="params" value="${fn:split(params,',')}"/>
<c:set var="pageNo" value="${1*params[0]}"/>
<c:set var="pageSize" value="${1*params[1]}"/>
<c:set var="total" value="${1*params[2]}"/>
<c:set var="type1" value='${params[3] }'/>
<c:set var="type2" value='${params[4] }'/>
<c:set var="pageTotal">${(total-1)/pageSize+1}</c:set>
<c:set var="pageTotal" value="${fn:substring(pageTotal,0,fn:indexOf(pageTotal,'.'))}"/>
<c:set var="begin" value="${pageNo > 4 ? pageNo - 3 : 1}"/>
<c:set var="end" value="${pageTotal - pageNo > 3 ? pageNo + 3 : pageTotal}"/>
<c:set var="urlPrefix" value='<%=(request.getAttribute("ROOT"))%>'/>
<c:forEach var="x" begin="1" end="${3-(pageNo-begin)}"><c:if test="${end < pageTotal}"><c:set var="end" value="${end+1}"/></c:if></c:forEach>
<c:forEach var="x" begin="1" end="${3-(end-pageNo)}"><c:if test="${begin>1}"><c:set var="begin" value="${begin-1}"/></c:if></c:forEach>
<c:if test="${pageNo > 2}">
<a class="prev" href="${urlPrefix}/${type1}/${type2}-${pageNo-1}.html">上一页</a>
</c:if>
<c:if test="${pageNo == 2}">
<a class="prev" href="${urlPrefix}/${type1}/">上一页</a>
</c:if>
<c:if test="${pageNo > 4 && pageTotal > 7}"><a href="${urlPrefix}/${type1}/">1</a> ... </c:if>
<c:if test="${end>1 }">
<c:forEach var="n" begin="${begin}" end="${end}">
<c:if test="${n != pageNo && n!=1}">
<a href="${urlPrefix}/${type1}/${type2}-${n}.html">${n}</a>
</c:if>
<c:if test="${n==1 && pageNo!=1}">
    <a href="${urlPrefix}/${type1}/">${n}</a>
</c:if>
<c:if test="${n == pageNo}"><span>${n}</span></c:if>
</c:forEach>
</c:if>
<c:if test="${pageNo < pageTotal - 3 && pageTotal > 7}"> ... <a href="${urlPrefix}/${type1}/${type2}-${pageTotal}.html">${pageTotal}</a></c:if>
<c:if test="${pageNo < pageTotal}">
<a class="next" href="${urlPrefix}/${type1}/${type2}-${pageNo+1}.html">下一页</a></c:if>